package com.flymobi.mshop.adapter;

import java.util.List;
import java.util.Map;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.flymobi.mshop.R;
import com.flymobi.mshop.activity.FillOrder;
import com.flymobi.mshop.util.Constants;

public class PersonalCenterAdapter extends BaseAdapter{
	private Context mContext;
	private List<Map<String,Object>> list;
	public PersonalCenterAdapter(
			Context mContext,
			List<Map<String,Object>> list) {
		this.mContext=mContext;
		this.list=list;
	}
	@Override
	public int getCount() {
		if (list == null)
			return 0;
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}
	private TextView orderId;
	private TextView zhuangtai;
	private TextView number;
	private TextView date;
	private String code;
	private String zt;
	private String zongjia;
	private String time;
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		convertView = View.inflate(mContext, R.layout.order, null);
		orderId = (TextView) convertView.findViewById(R.id.orderId);
		zhuangtai = (TextView) convertView.findViewById(R.id.zhuangtai);
		number = (TextView) convertView.findViewById(R.id.number);
		date = (TextView) convertView.findViewById(R.id.date);
		Map<String, Object> map = list.get(position);
		code=map.get("code").toString();
		FillOrder.valueMap.put("code", code);
		zt=map.get("state").toString();
		zongjia=map.get("zfe").toString();
		time=map.get("orderTime").toString();
		ifStatus();
		orderId.setText(code);
		zhuangtai.setText(zt);
		number.setText("¥"+zongjia);
		date.setText(time);
		return convertView;
	}
	
	private void ifStatus(){
		if(zt.equals(Constants.DD.STATUS.CANCEL)){
			zt="取消订单";
		}
		if(zt.equals(Constants.DD.STATUS.WAIT_PAY)){
			zt="待付款";
		}
		if(zt.equals(Constants.DD.STATUS.WAIT_FAHUO)){
			zt="待发货";
		}
		if(zt.equals(Constants.DD.STATUS.PEIHUO)){
			zt="配货中";
		}
		if(zt.equals(Constants.DD.STATUS.ALREADY_FAHUO)){
			zt="已发货";
		}
		if(zt.equals(Constants.DD.STATUS.ALREADY_RECVED)){
			zt="确认收货";
		}
		if(zt.equals(Constants.DD.STATUS.SUCCESS)){
			zt="交易成功";
		}
		if(zt.equals(Constants.DD.STATUS.TUIHUO_REQ)){
			zt="申请退货";
		}
		if(zt.equals(Constants.DD.STATUS.TUIHUO_REQ_OK)){
			zt="申请退货通过，可退货";
		}
		if(zt.equals(Constants.DD.STATUS.TUIHUO_REQ_CANCEL)){
			zt="申请退货不通过";
		}
		if(zt.equals(Constants.DD.STATUS.TUIHUO)){
			zt="退货中";
		}
		if(zt.equals(Constants.DD.STATUS.TUIHUO_OK)){
			zt="退货收到确认";
		}
		if(zt.equals(Constants.DD.STATUS.TUIHUO_SUCCESS)){
			zt="退货完成";
		}
		if(zt.equals(Constants.DD.STATUS.TUIKUAN)){
			zt="退款中";
		}
		if(zt.equals(Constants.DD.STATUS.TUIKUAN_OK)){
			zt="已退款";
		}
		if(zt.equals(Constants.DD.STATUS.HUANHUO)){
			zt="换货";
		}
		if(zt.equals(Constants.DD.STATUS.HUANHUO_OK)){
			zt="换货退回确认收到";
		}
	}

}
